import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:get/get.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:common_utils/common_utils.dart';

class DelDialog extends Dialog {

  final String title;
  final String message;
  final Function onTap;
  DelDialog({ this.title = '', required this.message, required this.onTap });

  @override
  Widget build(BuildContext context) {
    return Material(
      type: MaterialType.transparency,
      child: Center(
        child: Container(
          width: 320.w,
          decoration: BoxDecoration(
            color: bgWhiteColor,
            borderRadius: BorderRadius.circular(12.w)
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Container(
                padding: EdgeInsets.symmetric(vertical: 32.h, horizontal: 25.w),
                child: Column(
                  children: [
                    TextUtil.isEmpty(title) ? Container() : Column(
                      children: [
                        Text(
                          title,
                          style: TextStyle(
                            color: textBlackColor,
                            fontSize: 20.sp
                          ),
                        ),
                        SizedBox(height: 21.h)
                      ],
                    ),
                    Text(
                      message,
                      style: TextStyle(
                        fontSize: TextUtil.isEmpty(title) ? 20.sp : 16.sp,
                        color: TextUtil.isEmpty(title) ? textBlackColor : textSubtitleColor
                      ),
                    )
                  ],
                ),
              ),
              Container(
                height: 55.h,
                decoration: BoxDecoration(
                  border: Border(
                    top: BorderSide(
                      width: .5,
                      color: lineColor
                    )
                  )
                ),
                child: Row(
                  children: [
                    InkWellUtil.shakeProofInkWell(Container(
                      width: 160.w,
                      height: 55.h,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        border: Border(
                          right: BorderSide(
                            width: .5,
                            color: lineColor
                          )
                        )
                      ),
                      child: Text(
                        '取消',
                        style: TextStyle(
                          fontSize: 16.sp,
                          color: textSubtitleColor
                        ),
                      ),
                    ), () async {
                      Get.back();
                    },
                    hoverColor: Colors.transparent,
                    splashColor: Colors.transparent,
                    highlightColor: Colors.transparent),
                    InkWellUtil.shakeProofInkWell(Container(
                      width: 159.w,
                      height: 55.h,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.only(
                          bottomRight: Radius.circular(12.w),
                        )
                      ),
                      child: Text(
                        '确定',
                        style: TextStyle(
                          fontSize: 16.sp,
                          color: mainTextColor
                        ),
                      ),
                    ), () async {
                      Get.back();
                      onTap();
                    },
                    hoverColor: Colors.transparent,
                    splashColor: Colors.transparent,
                    highlightColor: Colors.transparent)
                  ],
                )
              )
            ],
          ),
        ),
      ),
    );
  }
}